{extend name="admin/b2c/base" /}
{block name="main"}
<div class="set-style">
	<dl>
		<dt>应用ID[AppID]:</dt>
		<dd><input name="" id="APP_KEY" type="text" value="{$config['oauth_value']['appid']}"/></dd>
	</dl>
	<dl>
		<dt>应用密钥[AppSecrect]:</dt>
		<dd><input name="" id="APP_SECRET" type="text" value="{$config['oauth_value']['appkey']}"/></dd>
	</dl>
		<dl>
		<dt>支付专用签名串[paySignKey]:</dt>
		<dd><input name="" id="paySignKey" type="text" value="{$config['oauth_value']['mch_key']}"/></dd>
	</dl>
	<dl>
		<dt>微信支付商户号[MCHID]:</dt>
		<dd><input name="" id="MCHID" type="text" value="{$config['oauth_value']['mch_id']}"/></dd>
	</dl>
	<dl>
		<dt>是否启用:</dt>
		<dd>
			<p>
					<input id="is_use" type="checkbox" class="checkbox" {if condition="$config.is_use==1"} checked="checked"{/if}/>
			</p>
		</dd>
	</dl>
	<button class="edit_button" onclick="setConfigAjax()">提交</button>
</div>
{include file="admin/b2c/openDialog" /}
<script>
	function setConfigAjax(){
		var appkey = $("#APP_KEY").val();
		var appsecret = $("#APP_SECRET").val();
		var paySignKey = $("#paySignKey").val();
		var MCHID = $("#MCHID").val();
		var is_use = 0;
		if($("#is_use").is(":checked")){
			is_use = 1;
		}
		$.ajax({
			type:"post",
			url:"ADMIN_MAIN/Config/payConfig",
			data:{
				'appkey':appkey,
				'appsecret':appsecret,
				'paySignKey':paySignKey,
				'MCHID':MCHID,
				'type':'wchat',
				'is_use' : is_use
			},
			async:true,
			success:function (data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"],'');
				}else{
					showMessage('error', data["message"]);
				}
			}
		});
	}
</script>
{/block}